package practice_0526;

public class practice03 {

    public static void main(String[] args) throws InterruptedException {
        Person2 person = new Person2();
        person.setName("老韩");
        person.setPriority(Thread.MIN_PRIORITY);
        person.start();
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+ i);
            person.interrupt();
        }
        System.out.println(person.getName() + "线程优先级是："+ person.getPriority());



    }
}

class Person2 extends Thread{
    boolean loop = true;
    @Override
    public void run() {
        while(true) {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread().getName()+"吃了包子"+  i);
            }
            try {
                System.out.println("休眠十秒....");
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().getName()+ "休眠被打断");
            }

        }
    }

    public void setLoop(boolean loop) {
        this.loop = loop;
    }
}

